package com.Studen.controller;

import com.Studen.bean.Score;
import com.Studen.servlet.DDLServlet;
import com.Studen.servlet.DDLServletMpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/update")
public class UpdateController extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /**
         * 获取前台传来的要修改的成绩x传到controller层用来和数据库相关操作
         * 获取修改后的成绩传到前台进行可视化
         *
         * **/

        int x= Integer.parseInt(request.getParameter("x"));
        int id=Integer.parseInt(request.getParameter("id"));
        System.out.println(x);
        System.out.println(id);
        DDLServlet l = new DDLServletMpl();
        List<Score>score=l.Update(x,id);
        request.setAttribute("score",score);
        request.getRequestDispatcher("ShowScore.jsp").forward(request,response);

    }
}
